package com.tengju.user.domain.model.sign;

import com.tengju.user.domain.model.user.StarLevelEnum;
import com.tengju.user.domain.model.user.UserInfo;
import com.tengju.user.domain.shared.DomainException;
import com.tengju.user.domain.shared.DomainExceptionCode;
import java.time.LocalDateTime;
import org.springframework.util.StringUtils;

public class StarBlacklistFactory {

    public static StarBlacklist create(UserInfo userInfo, StarLevelEnum starLevelEnum,
            String createBy) {
        if (null == userInfo) {
            throw DomainException.error(DomainExceptionCode.INVALID_DATA, "用户信息为空");
        }
        if (null == starLevelEnum) {
            throw DomainException.error(DomainExceptionCode.INVALID_DATA, "限制等级为空");
        }
        if (StringUtils.isEmpty(createBy)) {
            throw DomainException.error(DomainExceptionCode.INVALID_DATA, "操作人为空");
        }
        return new StarBlacklist(
                null,
                userInfo.getIdCode(),
                userInfo.getMobile(),
                starLevelEnum,
                StarBlacklistValidStatusEnum.VALID,
                createBy, createBy,
                LocalDateTime.now());
    }
}
